<template>
  <div class="worddetail_wrapper" >
    <div class="worddetail_inner">
      <DetailTop :word_data="word_data"></DetailTop>
      <DetailCenter :word_data="word_data" v-on:loadWord = "loadWord"></DetailCenter>

    </div>
  </div>
</template>

<script>
  import DetailTop from "../detail_top/DetailTop";
  import {mapState, mapGetters} from 'vuex'
  import {getRequest} from "../../utils/api";
  import DetailCenter from "../detail_top/DetailCenter";
  import {strsutils} from "../../utils/strutils";
  let baseurl = strsutils.baseurl
  export default {
      name: "WordDetail",
      methods:{
        loadWord(){
          let _this = this
          // console.debug("worid:"+this.word_detail_id)
          let wordid = window.localStorage.getItem('cur_wordid')
          getRequest(baseurl+'/word/'+wordid, '').then(function (res) {
            console.debug("word_detail 获取word成功："+JSON.stringify(res.data))
            _this.word_data = res.data
          }).catch(function (err) {
            console.debug("word_detail 获取word失败："+err)
          })
        }
      },
      data(){
        return {
          word_data: {
            id: 0,
            userid: 0,
            src: 'src',
            tgt: 'tgt',
            cmd: 'cmd',
            imp: 'imp',
            features: []
          }
        }
      },
      computed: {
        ...mapState(['word_detail_id']),
        ...mapGetters({})
      },
      mounted() {
        this.loadWord()
      },
      components:{DetailTop, DetailCenter}
    }
</script>

<style scoped>

</style>
